/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.modules.insurance.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author Hehh
* @date 2021-12-24
**/
@Entity
@Data
@Table(name="i_insurance_scheme")
public class InsuranceScheme implements Serializable {

    private static final long serialVersionUID = 7952875345324698259L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "id")
    private Long id;

    @Column(name = "create_user_id")
    @ApiModelProperty(value = "创建人")
    private Long createUserId;

    @Column(name = "is_deleted")
    @ApiModelProperty(value = "是否删除")
    private Integer isDeleted;

    @Column(name = "create_time")
    @CreationTimestamp
    @ApiModelProperty(value = "创建日期")
    private Timestamp createTime;

    @Column(name = "scheme_no",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "方案编号")
    private String schemeNo;

    @Column(name = "insurance_type",nullable = false)
    @NotNull
    @ApiModelProperty(value = "保险方案0主险,1附加险")
    private Integer insuranceType;

    @Column(name = "file_name")
    @ApiModelProperty(value = "文件名称")
    private String fileName;

    @Column(name = "access_url")
    @ApiModelProperty(value = "访问地址")
    private String accessUrl;

    @Column(name = "owner_id",nullable = false)
    @ApiModelProperty(value = "所属人ID")
    private Long ownerId;

    /**
     * 创建用户名
     */
    @Transient
    private String createUserName;

    public void copy(InsuranceScheme source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}